﻿<%@ Page Language="C#"  Title="资金受限条件养护方案"  MasterPageFile="~/W_View/PageMaster.Master"  CodeBehind="DF_FunlimprojPage.aspx.cs" Inherits="STHPMS1.Web.W_View.Decision.Fondos.DF_FunlimprojPage" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <%= UiHelper.RefJsFileHtml("/Scripts/Control/datagrid.js")%>
    <%= UiHelper.RefJsFileHtml("/Scripts/Control/dropdown.js")%>
    <%= UiHelper.RefJsFileHtml("/Scripts/Jquery/ajaxfileupload.js")%>

    <script type="text/javascript">
        //同步数据
        function SetInsert() {
            var anni_name = $('#cmbRoads').combobox("getText"); //资金模型名称
            var analy_year = $('#cmbAnalyYear').combobox("getText"); //分析年度
            if (!anni_name && !analy_year) {
                $.messager.alert('消息提示', '请选择资金模型和分析年度！', 'warning');
                return;
            }
            $.messager.progress({
                title: '请等待',
                msg: '加载数据中...'
            });

            $.ajax({
                url: "/api/dffunlimproj/SetInsert?anniname=" + anni_name + "&analy_year=" + analy_year + "",
                type: "GET",
                success: function () {
                    $.messager.progress('close');
                    $.messager.alert('成功', '同步成功!', "info");
                    //$('#cmbRoads').combobox("setValue", road);
                    $('#dg').datagrid({ url: '/api/dffunlimproj', pageNumber: 1 });
                },
                error: function (err) {
                    $.messager.progress('close');
                    $.messager.alert('错误提示', '同步失败 -' + err, "error");
                }
            });
        }

        //资金安排
        function SetEditYear() {
            var anni_name = $('#cmbRoads').combobox("getText"); //资金模型名称
            var analy_year = $('#cmbAnalyYear').combobox("getText"); //分析年度
            if (!anni_name && !analy_year) {
                $.messager.alert('消息提示', '请选择资金模型和分析年度！', 'warning');
                return;
            }
            $.messager.progress({
                title: '请等待',
                msg: '加载数据中...'
            });

            $.ajax({
                url: "/api/dffunlimproj/SetEditYear?anniname=" + anni_name + "&analy_year=" + analy_year + "",
                type: "GET",
                success: function () {
                    $.messager.progress('close');
                    $.messager.alert('成功', '资金安排成功!', "info");
                    $('#cmbRoads').combobox("setValue", road);
                    $('#dg').datagrid({ url: '/api/dffunlimproj?anni_name=' + anni_name + '&analy_year=' + analy_year, pageNumber: 1 });
                },
                error: function (err) {
                    $.messager.progress('close');
                    $.messager.alert('错误提示', '资金安排失败 -' + err, "error");
                }
            });
        }


        function search(n, o) {
            var anni_name = $('#cmbRoads').combobox("getText"); //资金模型名称
            var analy_year = $('#cmbAnalyYear').combobox("getText"); //分析年度

            var url = '/api/dffunlimproj';
            var urlParam = "";
            if (anni_name != "" && anni_name != "0") urlParam += "anni_name=" + encodeURI(anni_name) + "&";
            if (analy_year != "" && analy_year != "0") urlParam += "analy_year=" + encodeURI(analy_year) + "&";
            if (urlParam != "") {
                urlParam = "?" + urlParam.substring(0, urlParam.length - 1);
                url = url + urlParam;
            }

            $('#dg').datagrid({ url: url, pageNumber: 1 });
        }


        $(function () {
            var number = '<%= Page.RouteData.Values["page"] %>';
            var size = '<%= Page.RouteData.Values["size"] %>';

            loadAdmDiv();
            dataGridBind($('#dg'), '/api/dffunlimproj', '资金受限条件养护方案', $('#tb'), number, size);

            $('.validatebox-text').bind('blur', function () {
                $(this).validatebox('enableValidation').validatebox('validate');
            });
        })

    </script>    

    
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <table id="dg" class="easyui-datagrid content-place"  ajaxCached="false"  >
        <thead>
            <th data-options="field:'Id',editor:'text',width:80,align:'right',hidden:true">ID</th>
            <th data-options="field:'Anni_Name',editor:'numberbox',width:150,align:'right' ">资金模型名称</th>
            <th data-options="field:'Roadnet_Name',editor:'text',width:100,align:'right' " >路网名称</th>
            <th data-options="field:'Rdwayid',editor:'text',width:80,align:'right' ">路线编号</th>
            <th data-options="field:'Mainsegid',editor:'text',width:250,align:'right' ">养护路段</th>
            <th data-options="field:'Beginmp',editor:'text',width:80,align:'right' ">起点桩号</th>
            <th data-options="field:'Endmp',editor:'text',width:80,align:'right' ">终点桩号</th>
            <th data-options="field:'Rd_Class',editor:'text',width:80,align:'right' " formatter="formatRoadClass">公路等级</th>
            <th data-options="field:'Segid_Main',editor:'text',width:80,align:'right' " formatter="formatMainType">养护方案</th>
            <th data-options="field:'Carry_Year',editor:'text',width:80,align:'right' ">实施年度</th>
            <th data-options="field:'Segid_Maincost',editor:'text',width:150,align:'right' " formatter="formatNumber">路段养护维修费用/万元</th>
            <th data-options="field:'Analy_Year',editor:'text',width:80,align:'right' ">分析年度</th>
            <th data-options="field:'Pci',editor:'text',width:80,align:'right' ">PCI</th>
            <%--<th data-options="field:'Pqi',editor:'text',width:80,align:'right' ">PCQI</th>--%>
            <th data-options="field:'Ordernum',editor:'text',width:80,align:'right' ">顺序</th>
            <th data-options="field:'Cost_Year',editor:'text',width:80,align:'right' ">资金分配年度</th>

        </thead>
    </table>
   
    <div id="tb">
        <select id="cmbRoads" class="easyui-combobox" panelHeight="80" style="width:100px" data-options="prompt:'资金模型名称',url:'/api/dfcostmodpara/anniname?annutype=20021',method:'get',valueField:'id',textField:'id',onChange:search,onSelect:function(rect){ 
                            var stfu_url = '/api/dfcostmodpara/AnalyYear?anni_name='+rect.id;
                             
                            $('#cmbAnalyYear').combobox('reload', stfu_url).combobox('clear');
                        }">
         </select>

        <select id="cmbAnalyYear" class="easyui-combobox" panelHeight="80" style="width:100px" data-options="prompt:'分析年度',method:'get',valueField:'id',textField:'id',onChange:search">
         </select>
        <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-reload',plain:true" onclick="SetInsert()">同步数据</a>

        <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-reload',plain:true" onclick="SetEditYear()">资金安排</a>

        
    </div>

    

    
</asp:Content>